-
Notifications
You must be signed in to change notification settings - Fork 23
fix(dashboard): begin caching calls and moving reused functions to server actions #4654
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(dashboard): begin caching calls and moving reused functions to server actions #4654
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
This stack of pull requests is managed by Graphite. Learn more about stacking. |
packages/fern-dashboard/src/app/actions/getDocsGithubMetadata.ts
Outdated
Show resolved
Hide resolved
packages/fern-dashboard/src/app/[orgName]/(homepage)/docs/[docsUrl]/page.tsx
Outdated
Show resolved
Hide resolved
141159e to
fbdf387
Compare
45fb737 to
ac6000f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additional Suggestion:
The getFernVersionUpdateInfo function signature has been changed to accept three positional parameters instead of a single object, but this call site still uses the old object syntax.
View Details
📝 Patch Details
diff --git a/packages/fern-dashboard/src/components/docs-page/visual-editor-section/CriticalUpdateWarning.tsx b/packages/fern-dashboard/src/components/docs-page/visual-editor-section/CriticalUpdateWarning.tsx
index d5a72d522..95da90dd8 100644
--- a/packages/fern-dashboard/src/components/docs-page/visual-editor-section/CriticalUpdateWarning.tsx
+++ b/packages/fern-dashboard/src/components/docs-page/visual-editor-section/CriticalUpdateWarning.tsx
@@ -16,11 +16,7 @@ export async function CriticalUpdateWarning({
githubUrl: string;
baseBranch: string;
}) {
- const fernVersionInfoResult = await getFernVersionUpdateInfo({
- githubUrl,
- docsUrl,
- baseBranch
- });
+ const fernVersionInfoResult = await getFernVersionUpdateInfo(githubUrl, docsUrl, baseBranch);
const fernVersionInfo = fernVersionInfoResult.ok ? fernVersionInfoResult.result : undefined;
Analysis
Function call uses outdated object syntax instead of positional parameters
What fails: getFernVersionUpdateInfo() call in CriticalUpdateWarning.tsx uses object destructuring syntax, but function now expects 3 positional parameters
How to reproduce:
cd packages/fern-dashboard && pnpm run typecheckResult: TypeScript error: src/components/docs-page/visual-editor-section/CriticalUpdateWarning.tsx(19,41): error TS2554: Expected 3 arguments, but got 1.
Expected: Function should be called with positional parameters: getFernVersionUpdateInfo(githubUrl, docsUrl, baseBranch) matching the updated signature in getFernVersionUpdateInfo.ts
| if (githubUrl == null || baseBranch == null || docsUrl == null) { | ||
| return { ok: false, error: { type: "MALFORMED_INPUT" } }; | ||
| } | ||
| import { cache } from "react"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The import { cache } from "react" statement is placed after type exports instead of at the top with other imports, violating TypeScript import conventions.
View Details
📝 Patch Details
diff --git a/packages/fern-dashboard/src/app/services/dal/github/getFernVersionUpdateInfo.ts b/packages/fern-dashboard/src/app/services/dal/github/getFernVersionUpdateInfo.ts
index eb5ea3e7f..cd4a449bf 100644
--- a/packages/fern-dashboard/src/app/services/dal/github/getFernVersionUpdateInfo.ts
+++ b/packages/fern-dashboard/src/app/services/dal/github/getFernVersionUpdateInfo.ts
@@ -1,67 +1,88 @@
import "server-only";
-import { compareVersions, getLatestFernCliVersion, MIN_VE_CLI_VERSION } from "@/utils/fernCliVersion";
+import { cache } from "react";
+
+import {
+ MIN_VE_CLI_VERSION,
+ compareVersions,
+ getLatestFernCliVersion,
+} from "@/utils/fernCliVersion";
import type { DocsUrl } from "@/utils/types";
import { checkUpgradePrStatus } from "./checkUpgradePrStatus";
-import { type GetFernVersionFromRepoError, getFernVersionFromRepo } from "./getFernVersionFromRepo";
+import {
+ type GetFernVersionFromRepoError,
+ getFernVersionFromRepo,
+} from "./getFernVersionFromRepo";
export type GetFernVersionUpdateInfoResult = {
- current: string;
- latest: string;
- needsUpgrade: boolean;
- isBelowMinimum: boolean;
- existingPr?: {
- exists: boolean;
- prUrl?: string;
- prNumber?: number;
- };
+ current: string;
+ latest: string;
+ needsUpgrade: boolean;
+ isBelowMinimum: boolean;
+ existingPr?: {
+ exists: boolean;
+ prUrl?: string;
+ prNumber?: number;
+ };
};
-export type GetFernVersionUpdateInfoError = GetFernVersionFromRepoError | { type: "MALFORMED_INPUT" };
-
-import { cache } from "react";
+export type GetFernVersionUpdateInfoError =
+ | GetFernVersionFromRepoError
+ | { type: "MALFORMED_INPUT" };
export const getFernVersionUpdateInfo = cache(
- async (
- githubUrl: string,
- docsUrl: DocsUrl,
- baseBranch: string
- ): Promise<
- { ok: true; result: GetFernVersionUpdateInfoResult } | { ok: false; error: GetFernVersionUpdateInfoError }
- > => {
- if (githubUrl == null || baseBranch == null || docsUrl == null) {
- return { ok: false, error: { type: "MALFORMED_INPUT" } };
- }
+ async (
+ githubUrl: string,
+ docsUrl: DocsUrl,
+ baseBranch: string
+ ): Promise<
+ | { ok: true; result: GetFernVersionUpdateInfoResult }
+ | { ok: false; error: GetFernVersionUpdateInfoError }
+ > => {
+ if (githubUrl == null || baseBranch == null || docsUrl == null) {
+ return { ok: false, error: { type: "MALFORMED_INPUT" } };
+ }
- const [fernVersionResult, latestVersion] = await Promise.all([
- getFernVersionFromRepo(githubUrl, docsUrl),
- getLatestFernCliVersion()
- ]);
+ const [fernVersionResult, latestVersion] = await Promise.all([
+ getFernVersionFromRepo(githubUrl, docsUrl),
+ getLatestFernCliVersion(),
+ ]);
- if (!fernVersionResult.ok) {
- return { ok: false, error: fernVersionResult.error };
- }
+ if (!fernVersionResult.ok) {
+ return { ok: false, error: fernVersionResult.error };
+ }
- const needsUpgrade = compareVersions(fernVersionResult.version, latestVersion);
- const isBelowMinimum = compareVersions(fernVersionResult.version, MIN_VE_CLI_VERSION);
+ const needsUpgrade = compareVersions(
+ fernVersionResult.version,
+ latestVersion
+ );
+ const isBelowMinimum = compareVersions(
+ fernVersionResult.version,
+ MIN_VE_CLI_VERSION
+ );
- let existingPr;
+ let existingPr;
- // Show version info if any update is available
- if (needsUpgrade) {
- // Check if there's already an existing upgrade PR
- existingPr = await checkUpgradePrStatus(githubUrl, fernVersionResult.version, latestVersion, baseBranch);
- }
- return {
- ok: true,
- result: {
- current: fernVersionResult.version,
- latest: latestVersion,
- needsUpgrade,
- isBelowMinimum,
- existingPr
- }
- };
+ // Show version info if any update is available
+ if (needsUpgrade) {
+ // Check if there's already an existing upgrade PR
+ existingPr = await checkUpgradePrStatus(
+ githubUrl,
+ fernVersionResult.version,
+ latestVersion,
+ baseBranch
+ );
}
+ return {
+ ok: true,
+ result: {
+ current: fernVersionResult.version,
+ latest: latestVersion,
+ needsUpgrade,
+ isBelowMinimum,
+ existingPr,
+ },
+ };
+ }
);
Analysis
Import statement placed after exports violates Prettier formatting rules in getFernVersionUpdateInfo.ts
What fails: import { cache } from "react" is placed after type exports instead of with other imports, violating the project's Prettier import sorting configuration
How to reproduce:
cd packages/fern-dashboard
pnpm exec prettier --check src/app/services/dal/github/getFernVersionUpdateInfo.tsResult: Prettier reports "Code style issues found" due to React import being placed after exports instead of in proper import group order
Expected: React imports should be grouped near the top per the project's .prettierrc.json import ordering rules: ["server-only", "^(react*|next*)", "<THIRD_PARTY_MODULES>", ...]
7d00164 to
5124751
Compare

Fixes FER-7344
Short description of the changes made
What was the motivation & context behind this PR?
How has this PR been tested?